/**
 * @date 2005-12-26 14:01:52
 *
 */
package org.nanhill.commons.pattern.strategy;

/**
 * @author alin
 * 
 */

/**
 * ��Ա��
 * 
 * @author alin
 * 
 */
public interface DiscountStrategy {
	double getDiscount();
}

/**
 * �ƽ�
 * 
 * @author alin
 * 
 */
class GoldenDiscount implements DiscountStrategy {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.nanhill.base.pattern.strategy.DiscountStrategy#getDiscount()
	 */
	public double getDiscount() {
		return 0.3;
	}

}

/**
 * ����
 * 
 * @author alin
 * 
 */
class SilverDiscount implements DiscountStrategy {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.nanhill.base.pattern.strategy.DiscountStrategy#getDiscount()
	 */
	public double getDiscount() {
		return 0.1;
	}

}

/**
 * ��Ա�ӿ�
 * 
 * @author alin
 * 
 */
interface Member {
	double getDiscount();
}

/**
 * �����Ա
 * 
 * @author alin
 * 
 */
abstract class AbstractMember implements Member {
	protected DiscountStrategy strategy;

	protected AbstractMember(DiscountStrategy strategy) {
		this.strategy = strategy;
	}

}

/**
 * Ů�Ի�Ա
 * 
 * @author alin
 * 
 */
class FemaleMember extends AbstractMember {
	FemaleMember(DiscountStrategy strategy) {
		super(strategy);
	}

	public double getDiscount() {
		return strategy.getDiscount() + 0.1;
	}

}

/**
 * ���Ի�Ա
 * 
 * @author alin
 * 
 */
class MaleMember extends AbstractMember {
	MaleMember(DiscountStrategy strategy) {
		super(strategy);
	}

	public double getDiscount() {
		return strategy.getDiscount();
	}

}
